package com.company.action;

import org.apache.struts2.ServletActionContext;

import com.company.entity.CompanyInfo;
import com.company.entity.Contacts;
import com.company.entity.Guanjianci;
import com.company.service.CompanyinfoService;
import com.company.service.ContactsService;
import com.company.service.GuanjianciService;
import com.company.service.PageNewsService;
import com.opensymphony.xwork2.ActionContext;

public class IndexAction extends BaseAction {

	CompanyinfoService companyinfoService;
	CompanyInfo companyInfo;
	Contacts contacts;
	ContactsService contactsService;
	PageNewsService pageNewsService;
	Guanjianci guanjianci;
	GuanjianciService guanjianciService;

	public Guanjianci getGuanjianci() {
		return guanjianci;
	}

	public void setGuanjianci(Guanjianci guanjianci) {
		this.guanjianci = guanjianci;
	}

	public GuanjianciService getGuanjianciService() {
		return guanjianciService;
	}

	public void setGuanjianciService(GuanjianciService guanjianciService) {
		this.guanjianciService = guanjianciService;
	}

	public PageNewsService getPageNewsService() {
		return pageNewsService;
	}

	public void setPageNewsService(PageNewsService pageNewsService) {
		this.pageNewsService = pageNewsService;
	}

	public CompanyInfo getCompanyInfo() {
		return companyInfo;
	}

	public void setCompanyInfo(CompanyInfo companyInfo) {
		this.companyInfo = companyInfo;
	}

	public Contacts getContacts() {
		return contacts;
	}

	public void setContacts(Contacts contacts) {
		this.contacts = contacts;
	}

	public CompanyinfoService getCompanyinfoService() {
		return companyinfoService;
	}

	public void setCompanyinfoService(CompanyinfoService companyinfoService) {
		this.companyinfoService = companyinfoService;
	}

	public ContactsService getContactsService() {
		return contactsService;
	}

	public void setContactsService(ContactsService contactsService) {
		this.contactsService = contactsService;
	}

	public String execute() throws Exception {
		// TODO Auto-generated method stub
		setContacts(contactsService.query());
		ServletActionContext.getRequest().getSession()
				.setAttribute("name", contacts.getName());
		ServletActionContext.getRequest().getSession()
				.setAttribute("phone", contacts.getPhone());
		ServletActionContext.getRequest().getSession()
				.setAttribute("email", contacts.getEmail());
		ServletActionContext.getRequest().getSession()
				.setAttribute("address", contacts.getAddress());
		ServletActionContext.getRequest().getSession()
				.setAttribute("company_info", companyinfoService.query());
		ServletActionContext.getRequest().getSession()
				.setAttribute("Newlist", pageNewsService.querylast());
		ActionContext.getContext().getApplication().put("guanjianci", guanjianciService.query());
		
		return super.execute();
	}
}
